package computer;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.*;


class JMenuDemoSimple {
    JFrame mainJFrame;//构造一个框架
    JMenuBar mainMenuBar;//创建一个新的菜单栏
    JMenu fileMenu;//创建菜单栏中的一级菜单
    JMenuItem newItem;//创建一级菜单中的二级菜单

}
public class BorderLayoutExample extends JFrame implements ActionListener {

    public static void main(String[] args) {


            JFrame frame = new JFrame("计算器");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setSize(300, 200);


           //new BorderLayoutExample.JMenuDemoSimple();

            JPanel panel = new JPanel(new BorderLayout());

            JTextField numtext = new JTextField(10);

            // JButton button = new JButton("编辑");
             //panel.add(button,BorderLayout.NORTH);
             panel.add(numtext, BorderLayout.NORTH);
        //createMenu();
            JPanel centerPanel = new JPanel(new FlowLayout());
            JButton button2 = new JButton("Backpace");
            JButton button3 = new JButton("C");
            centerPanel.add(button2);
            centerPanel.add(button3);
            panel.add(centerPanel, BorderLayout.CENTER);
            centerPanel.setPreferredSize(new Dimension(150, 30));


            JPanel southPanel = new JPanel(new GridLayout(5,4));
           // JFrame jFrame1=new JFrame("Java第四个GUI程序"); //创建Frame窗口
            //JPanel jPanel=new JPanel(); //创建面板
            JButton btn7=new JButton("7"); //创建按钮
            JButton btn8=new JButton("8");
            JButton btn9=new JButton("9");
            JButton btn10=new JButton("/");
            JButton btn4=new JButton("4");
            JButton btn5=new JButton("5");
            JButton btn6=new JButton("6");
            JButton btn11=new JButton("*");
            JButton btn1=new JButton("7");
            JButton btn2=new JButton("2");
            JButton btn3=new JButton("3");
            JButton btn12=new JButton("-");
        JButton btn0=new JButton("0");
        JButton btn17=new JButton("+/-");
        JButton btn18=new JButton(".");
        JButton btn19=new JButton("+");
            JButton btn13=new JButton("1/X");
            JButton btn14=new JButton("%");
            JButton btn15=new JButton("sqrt");
            JButton btn16=new JButton("=");
            southPanel.add(btn1); //面板中添加按钮
            southPanel.add(btn2);
            southPanel.add(btn3);
            southPanel.add(btn4);
            southPanel.add(btn5);
             southPanel.add(btn6);
             southPanel.add(btn7);
             southPanel.add(btn8);
              southPanel.add(btn9);
        southPanel.add(btn10);
        southPanel.add(btn11);
        southPanel.add(btn12);
        southPanel.add(btn0);
        southPanel.add(btn17);

        southPanel.add(btn18);
        southPanel.add(btn19);

        southPanel.add(btn13);
        southPanel.add(btn14);
        southPanel.add(btn15);
        southPanel.add(btn16);
          //  jPanel.setLayout(new FlowLayout(FlowLayout.LEADING,20,20));
           southPanel.setBackground(Color.gray); //设置背景色
            southPanel.setPreferredSize(new Dimension(150, 100));
//            jFrame1.add(jPanel); //添加面板到容器
//            jFrame1.setBounds(300,200,300,150); //设置容器的大小
//            jFrame1.setVisible(true);
//            jFrame1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            //JButton button4 = new JButton("South");
            panel.setSize(300,100);

            panel.add(southPanel, BorderLayout.SOUTH);

            frame.add(panel);
            frame.setVisible(true);
        }

    @Override
    public void actionPerformed(ActionEvent e) {

    }


//    @Override
//    public void actionPerformed(ActionEvent e) {
        //int n1 = Integer.parseInt(numtext.getText());
    }
